import { ExtractJwt, Strategy } from 'passport-jwt';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';
import App_configuration from '@/config/configuration'; // 全局配置

@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
  constructor() {
    super({
      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
      ignoreExpiration: false,
      secretOrKey: App_configuration().secret,
      // passReqToCallback: true,
    });
  }
  async validate(payload: any) {
    // throw new UnauthorizedException('token令牌非法，请重新登录！');
    return payload;
  }
}
